//
//  AXHdzqVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/30.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXHdzqVC.h"
#import "Header.h"
#import "ZXCategories.h"
#import "AXHdzqHomeVC.h"
#import "AXHdzqTgVC.h"
#import "AXHdzqMsVC.h"
#import "AXHdzqPdVC.h"
#import "AXHdzqYsVC.h"
#import "AXHdzqZqgVC.h"
#import "UIViewController+HBD.h"


@interface AXHdzqVC ()



@end

@implementation AXHdzqVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.pageTabView];
    [self setupNavigationItems];
    
     [PublicMonMethods settitle:@"活动专区" viewController:self];
   self.hbd_barShadowHidden = YES;
    
}



#pragma mark - Action

- (void)setupNavigationItems {
    
    /** 导航条左边的按钮 */
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    backBtn.frame = CGRectMake(0, 0, 30, 30);
    [backBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
  
    //右边按钮
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [shareBtn setImage:[UIImage imageNamed:@"share"] forState:UIControlStateNormal];
    shareBtn.frame = CGRectMake(0, 0, 60, 30);
    [shareBtn addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:shareBtn];
    self.navigationItem.rightBarButtonItem = rightItem;
    
   
    
}

- (void)backAction:(UIBarButtonItem *)item {
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)shareAction:(UIBarButtonItem *)item {
    
    [self.navigationController popViewControllerAnimated:YES];
}




- (XXPageTabView *)pageTabView
{
    if (!_pageTabView) {
        
        AXHdzqHomeVC *vc1 = [[AXHdzqHomeVC  alloc] init];
        [self addChildViewController:vc1];
        
        AXHdzqTgVC *vc2 = [[ AXHdzqTgVC alloc] init];
        [self addChildViewController:vc2];
        
        AXHdzqMsVC *vc3 = [[AXHdzqMsVC  alloc] init];
        [self addChildViewController:vc3];
        
        AXHdzqPdVC *vc4 = [[AXHdzqPdVC  alloc] init];
        [self addChildViewController:vc4];
        
        AXHdzqYsVC *vc5 = [[AXHdzqYsVC  alloc] init];
        [self addChildViewController:vc5];
        
        AXHdzqZqgVC *vc6 = [[AXHdzqZqgVC  alloc] init];
        [self addChildViewController:vc6];
        
        
        //支持网易云音乐，今日头条，微博等切换栏效果
        _pageTabView = [[XXPageTabView alloc] initWithChildControllers:self.childViewControllers childTitles:@[@"首页", @"团购",@"秒杀",@"拼单",@"预售",@"周期购"]];
        _pageTabView.frame = CGRectMake(0, Hn, Wi, Hi-Hn);
        
        _pageTabView.selectedTabIndex = 0;
        _pageTabView.maxNumberOfPageItems = 5;
        _pageTabView.tabSize = CGSizeMake(Wi, 44);
        _pageTabView.tabItemFont = FONT_FOURTEEN;
        
        _pageTabView.unSelectedColor = White(50);
        _pageTabView.selectedColor = COLOR_GREEN;
        
        _pageTabView.tabBackgroundColor = [UIColor whiteColor];
        
        //_pageTabView.separatorColor = [[UIColor grayColor] colorWithAlphaComponent:0.4];
        _pageTabView.bodyBounces = NO;
        
        _pageTabView.indicatorWidth = 0;
        _pageTabView.indicatorHeight = 2;
        
        _pageTabView.delegate = self;
        _pageTabView.titleStyle = XXPageTabTitleStyleDefault;
        _pageTabView.indicatorStyle = XXPageTabIndicatorStyleDefault;
        
        UIScrollView *bodyView = [_pageTabView valueForKey:@"bodyView"];
        [bodyView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
    }
    return _pageTabView;
}

- (void)pageTabViewDidEndChange
{
    DLog(@"page = %i", (int)self.pageTabView.selectedTabIndex);
}






@end

